using System;

using Jeffrey.XFramework.XCrawl;

namespace Jeffrey.XFramework
{
    public abstract class Filter
    {
        protected internal Filter(String name, String classname, String path)
            : this(name, "Null filter - accepts everything", classname, path) { }
        protected internal Filter(String name, String description, String classname, String path)
        {
            m_Name        = name;
            m_Description = description;
            m_ClassName   = classname;
            m_Path        = path;
            m_IsEnabled   = true;
        }

        public Boolean Accepts(CrawlUri uri)
        {
            if (!m_IsEnabled)
                return ifContinueProcessWhenDisabled();

            return innerAccepts(uri);
        }

        public String Name
        {
            get { return m_Name; }
        }
        public String Description
        {
            get { return m_Description; }
        }
        public String Path
        {
            get { return m_Path; }
        }
        public String ClassName
        {
            get { return m_ClassName; }
        }

        public Boolean Enabled
        {
            get { return m_IsEnabled; }
            set { m_IsEnabled = value; }
        }

        protected abstract Boolean innerAccepts(CrawlUri uri);
        protected virtual Boolean ifContinueProcessWhenDisabled()
        {
            //by default we return false...
            return false;
        }

        private String m_Name;
        private String m_Description;
        private String m_Path;
        private String m_ClassName;

        private Boolean m_IsEnabled;
    }
}
